# Maintainer: Felix Yan <felixonmars@archlinux.org>
# Contributor: Simon Sapin <simon dot sapin at exyr dot org>

pkgbase=python-cssselect
pkgname=('python-cssselect' 'python2-cssselect')
pkgver=1.0.3
pkgrel=2
license=('BSD')
arch=('any')
url="http://pypi.python.org/pypi/cssselect"
makedepends=('python-setuptools' 'python2-setuptools')
checkdepends=('python-pytest-runner' 'python2-pytest-runner' 'python-lxml' 'python2-lxml')
source=("$pkgbase-$pkgver.tar.gz::https://github.com/scrapy/cssselect/archive/v$pkgver.tar.gz")
sha512sums=('08feb3a515cc75089657a508cd1a80c6aaa97d710f27e99f9e749a1519adc13c5540134c6a4e0d7f548b022b8bd23dcbe360530d2329c5da36e43aca1f9627d1')

prepare() {
  cp -a cssselect-$pkgver{,-py2}
}

build() {
  cd "$srcdir"/cssselect-$pkgver
  python setup.py build

  cd "$srcdir"/cssselect-$pkgver-py2
  python2 setup.py build
}

check() {
  cd "$srcdir"/cssselect-$pkgver
  python setup.py pytest

  cd "$srcdir"/cssselect-$pkgver-py2
  python2 setup.py pytest
}

package_python-cssselect() {
  pkgdesc="A Python3 library that parses CSS3 Selectors and translates them to XPath 1.0"
  depends=('python')

  cd cssselect-$pkgver
  python setup.py install --root="$pkgdir" --optimize=1

  install -Dm644 LICENSE "$pkgdir"/usr/share/licenses/$pkgname/LICENSE
}

package_python2-cssselect() {
  pkgdesc="A Python2 library that parses CSS3 Selectors and translates them to XPath 1.0"
  depends=('python2')

  cd cssselect-$pkgver-py2
  python2 setup.py install --root="$pkgdir" --optimize=1
  
  install -Dm644 LICENSE "$pkgdir"/usr/share/licenses/$pkgname/LICENSE
}
